package com.practica.superTrivia;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class Credits extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.credits);
        
        TextView txt = (TextView)findViewById(R.id.creditsText);
        txt.setText(readTxt());
    }
    
    private String readTxt(){

        InputStream inputStream = getResources().openRawResource(R.raw.credits);
        
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        
        int i;
        try {
        	i = inputStream.read();
        	while (i != -1)
        	{
        		byteArrayOutputStream.write(i);
        		i = inputStream.read();
        	}

        	//cerramos el input
        	inputStream.close();
       	 
        } catch (IOException e) {
       	 // TODO Auto-generated catch block
       	 e.printStackTrace();
        }
        
        return byteArrayOutputStream.toString();
       }
    	
}
